// g++ ctry.cpp -std=c++11
#include <stdio.h>

class Base{
public:
    // Base() = default;
    virtual void show(){
        printf("method of Base::show()\n");
    }

    virtual void show2(){
        printf("method of Base::show2()\n");
    }

    void myself(){  // without virtual.
        printf("method of Base::myself()\n");
    }
};

class Derived: public Base{
public:
    virtual void show(){
        printf("method of Derived::show()\n");
    }

    void show2(){  // it would be run as virtual, though not written the keyword.
        printf("method of Derived::show2()\n");
    }

    void show3(){
        printf("A new method of Derived::show3()\n");
    }

    void myself(){
        printf("method of Derived::myself()\n");
    }
};

int main(){
    Base *father = new Derived();
    father->show();
    father->show2();
    // father->show3();  // fail to compile.
    father->myself();  // call the Base::myself()
    delete father;
}